<%--
  Created by IntelliJ IDEA.
  User: 86181
  Date: 2022/11/15
  Time: 11:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>出库申请审核模态框</title>
</head>
<body>
            <div class="modal-header">
                <input type="radio" name="rad" class="radexamin" checked value="0">通过
                <input type="radio" name="rad" class="radexamin" value="1">不通过
                <input type="button" onclick="examinelssuereqiosotionmodalbtnupdate()" class="btn btn-primary" value="提交">
                <button class="close" data-dismiss="modal">退出</button>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-offset-5"><h2>出库申请单</h2></div>
                </div>
                <br>
                <div class="row">
                    <div class="col-md-6">
                        <table>
                            <tr>
                                <td>申请单编号:</td>
                                <td><input type="text" id="eaxminelepayId" readonly style="outline: none;border: none;"></td>
                            </tr>
                            <tr>
                                <td>出库人:</td>
                                <td><input type="text" id="storereaxminel" readonly style="outline: none;border: none;"></td>
                            </tr>

                        </table>
                    </div>
                    <div class="col-md-6">
                        <table>
                            <tr>
                                <td>出库理由:</td>
                                <td><input type="text" id="reasoneaxminel" readonly style="outline: none;border: none;"></td>
                            </tr>
                        </table>
                    </div>
                </div>
                <br>
                <br>
                <div style="height:45%;">
                    <table id="examinelssuereqiosotionmodaltab">

                    </table>
                </div>
                <div class="row">
                    <div class="col-md-6">
                        <table>
                            <tr>
                                <td>总件数:</td>
                                <td><input type="text" id="eaxminelamountSum" readonly style="outline: none;border: none"></td>
                            </tr>
                            <tr>
                                <td>登记人:</td>
                                <td><input type="text" id="eaxminelregister" readonly style="outline: none;border: none ;border-bottom:1px black dashed"></td>
                            </tr>
                            <tr>
                                <td>复核人:</td>
                                <td><input type="text" id="eaxminelchecker" value="${username}" required style="outline: none;border: none; border-bottom:1px black dashed"></td>
                            </tr>
                        </table>
                    </div>
                    <div class="col-md-6">
                        <table>
                            <tr>
                                <td>总金额:</td>
                                <td><input type="text" id="eaxminelcostPriceSum" readonly style="outline: none;border: none"></td>
                            </tr>
                            <tr>
                                <td>登记时间:</td>
                                <td><input type="text" id="eaxminelregisterTime" readonly style="outline: none;border: none"></td>
                            </tr>
                            <tr>
                                <td>复核时间:</td>
                                <td><input type="text" id="eaxminelcheckTime"  readonly style="outline: none;border: none"></td>
                            </tr>
                        </table>
                    </div>
                </div>
                <br>
                <div>
                    <div class="form-group">
                        <label for="Issuerequisitionmodaltext"  class="control-label">配置要求:</label>
                        <textarea class="form-control" name="remark" id="Issuerequisitionmodaltext" style="width:800px;height:200px"></textarea>
                    </div>
                </div>
            </div>

            <script>
                //加载表格数据
                $(function () {
                    $("#examinelssuereqiosotionmodaltab").bootstrapTable({
                        sortable: true,//是否显示排序
                        sortOrder: "aso",//排序方式
                        sidePagination:"server", //分页方式：client客户端分页，server服务端分页（*）
                        showColumns: true,//是否显示所有的列（选择显示的列）
                        showRefresh: true,//是否显示刷新按钮
                        minimumCountColumns: 2,//最少允许的列数
                        showToggle: true,//是否显示详细视图和列表视图的切换按钮
                        cardView: false,//是否显示详细视图
                        detailView: false,//是否显示父子表,
                        columns:[
                            {
                                field:"",
                                title:"序号",
                                formatter:function (value,row,index) {
                                    return Number(index)+1
                                }
                            },
                            {
                                field:"productName",
                                title:"商品名称",
                            },
                            {
                                field:"productId",
                                title:"商品编号",
                            },
                            {
                                field:"cell",
                                title:"当前库存",
                                formatter:function (value,row,index) {
                                    return value.amount
                                }
                            },
                            {
                                field:"amount",
                                title:"数量",
                            },
                            {
                                field:"amountUnit",
                                title:"单位",
                            },
                            {
                                field:"costPrice",
                                title:"成本单价(元)",
                            },
                            {
                                field:"subtotal",
                                title:"小计",
                            }
                        ]
                    })
                })

                //加载查询语句
                $(function () {
                    //获取数据
                    var payId='${param.payId}'
                    $.post("queryByPayPayId.action",{"payId":payId},function (data) {
                        console.log(data)
                        //赋值
                        //申请单编号
                        $("#eaxminelepayId").val(data.payId)
                        //出库人
                        $("#storereaxminel").val(data.storer)
                        //出库理由
                        var reasons="";
                        if(data.reason=="C002-1"){
                            reasons="生产领料"
                        }
                        if(data.reason=="C002-2"){
                            reasons="赠送"
                        }
                        if(data.reason=="C002-3"){
                            reasons="内部借领"
                        }
                        if(data.reason==" C002-4"){
                            reasons="其他借领"
                        }
                        $("#reasoneaxminel").val(reasons)
                        //总件数
                        $("#eaxminelamountSum").val(data.amountSum)
                        //登记人
                        $("#eaxminelregister").val(data.register)
                        //总金额
                        $("#eaxminelcostPriceSum").val(data.costPriceSum)
                        //登记时间
                        $("#eaxminelregisterTime").val(data.registerTime)
                        //复核时间
                        //点击获取当前时间
                        $.get("queryCellByDate.action",function (data) {
                            $("#eaxminelcheckTime").val( datetimestack=data.datetime)
                        },"json")

                        //描述
                        $("#Issuerequisitionmodaltext").val(data.remark)
                        var arr=[]
                        var ars=data.payDetails;
                        for (var i=0;i<ars.length;i++){
                            arr.push(ars[i])
                        }
                        //加载表格数据
                        $("#examinelssuereqiosotionmodaltab").bootstrapTable("append",arr)
                    },"json")
                })
                
                //提交
                function examinelssuereqiosotionmodalbtnupdate() {

                   var rads=$(".radexamin:checked")
                   var rado;
                   $(rads).each(function (index,item) {
                        rado=item.value;
                   })

                    //获取值
                    var pey={
                        rad:rado,
                        payId:$("#eaxminelepayId").val(),
                        checker:$("#eaxminelchecker").val(),
                        checkTime:$("#eaxminelcheckTime").val()
                    }
                    console.log(pey)
                    $.ajax({
                        url:"updatePayByChecktag.action",
                        data:JSON.stringify(pey),
                        contentType:"application/json",
                        type:"post",
                        datatype:"json",
                        success:function (data) {
                            alert(data.msg)
                            $("#examinelssuereqiosotionmodal").modal("hide")
                            $("#examinelssuereqiosotiontab").bootstrapTable("refresh")
                        }
                    })
                }
            </script>
</body>
</html>
